﻿namespace Smart.Security.Excel.Core
{
    using System;

    internal class XlsBiffDimensions : XlsBiffRecord
    {
        private bool isV8;

        internal XlsBiffDimensions(byte[] bytes) : this(bytes, 0)
        {
        }

        internal XlsBiffDimensions(byte[] bytes, uint offset) : base(bytes, offset)
        {
            this.isV8 = true;
        }

        public ushort FirstColumn
        {
            get
            {
                return (this.isV8 ? base.ReadUInt16(8) : base.ReadUInt16(4));
            }
        }

        public uint FirstRow
        {
            get
            {
                return (this.isV8 ? base.ReadUInt32(0) : base.ReadUInt16(0));
            }
        }

        public bool IsV8
        {
            get
            {
                return this.isV8;
            }
            set
            {
                this.isV8 = value;
            }
        }

        public ushort LastColumn
        {
            get
            {
                return (this.isV8 ? base.ReadUInt16(0x10) : base.ReadUInt16(6));
            }
        }

        public uint LastRow
        {
            get
            {
                return (this.isV8 ? base.ReadUInt32(4) : base.ReadUInt16(2));
            }
        }
    }
}

